package com.zgc.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zgc.common.R;
import com.zgc.dto.DishDto;
import com.zgc.dto.OrderDto;
import com.zgc.entity.Category;
import com.zgc.entity.Dish;
import com.zgc.entity.OrderDetail;
import com.zgc.entity.Orders;
import com.zgc.service.OrderDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 订单明细
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderDetailController {
    @Autowired
    private OrderDetailService orderDetailService;
    /**
     * 订单查询
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public R<Page> page(int page, int pageSize){
        //分页构造器
        Page<OrderDetail> pageInfo = new Page<>(page,pageSize);
        //条件构造器
        LambdaQueryWrapper<OrderDetail> queryWrapper = new LambdaQueryWrapper<>();
        //添加排序条件，根据sort进行排序
        queryWrapper.orderByAsc(OrderDetail::getOrderId);
        //分页查询
        orderDetailService.page(pageInfo,queryWrapper);
        return R.success(pageInfo);
}
}
